//
//  SecondViewController.swift
//  WaiBao
//
//  Created by 赵佟越 on 17/5/11.
//  Copyright © 2017年 zhaotongyue. All rights reserved.
//

import UIKit
import DZNEmptyDataSet

class SecondViewController: BaseViewController ,UITableViewDelegate, UITableViewDataSource, DZNEmptyDataSetDelegate, DZNEmptyDataSetSource{

    override func viewDidLoad() {
        super.viewDidLoad()
        makeBaseUI()
        layoutNavigation()
        // Do any additional setup after loading the view.
    }

    //MARK: - Private Methods
    func makeBaseUI(){
        self.view .addSubview(self.myTableView)
        self.title = "列表"
    }
    func layoutNavigation(){
        
    }
    
    //MARK: - tableView Delegate And DataSource
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "cell")
        }
        if indexPath.section == 0{
            let mytextView = UITextView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 40))
            mytextView.font = UIFont.systemFont(ofSize: 17)
            cell?.contentView .addSubview(mytextView)
        }
        
        cell?.textLabel?.text = "1223"
        return cell!
    }
    //footer height
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return CGFloat.leastNormalMagnitude
    }
    // row height
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 40
    }
    // header height
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 30
    }
    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        if section == 0 {
            return "通知标题"
        }else if section == 1{
            return "正文内容"
        }else{
            return nil
        }
    }
    
    // row num
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    // 组数
    func numberOfSections(in tableView: UITableView) -> Int {
        return 5
    }
    
    //点击事件
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let vc = firstViewController()
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    override func willMove(toParentViewController parent: UIViewController?) {
        
    }
    
    // MARK: - 懒加载
    private lazy var myTableView:UITableView = {
        let myTableView = UITableView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight), style: UITableViewStyle.grouped)
        myTableView.delegate = self
        myTableView.dataSource = self
        myTableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
        return myTableView
    }()
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
